<?php
class Database {// Test databazy
    private $dbSetup=array(
        'db'=>'01077015_star',
        'dbHost'=>"a1europe.home.pl",
        'dbUser'=>"01077015_star",
        'dbPass'=>"znjz.%42NEMa",
    );

    public $dbh; // database handler
    private static $instance;

    private function __construct()
    {
        // building data source name from config
        $dsn = 'mysql:host='.$this->dbSetup['dbHost'] .
            ';dbname='.$this->dbSetup['db'];
        // getting DB user from config
        $user = $this->dbSetup['dbUser'];
        // getting DB password from config
        $password = $this->dbSetup['dbPass'];

        try{
            $this->dbh = new PDO($dsn, $user, $password);
            $this->dbh -> exec("SET CHARACTER SET utf8");
            $this->dbh -> exec("SET NAMES utf8");
            $this->dbh ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
        }
        catch(PDOException $e)
        {
            echo $e->getMessage();
        }
    }

    public static function getInstance()
    {
        if (!isset(self::$instance))
        {
            $object = __CLASS__;
            self::$instance = new $object;
        }
        return self::$instance;
    }
}

// Lepiej nie zakańczać plików PHP. tedy na 100% nie wystąpią dziwne krzaki.



